package main

//import (
//	_ "encoding/json"
//	"fmt"
//	"github.com/ethereum/go-ethereum/accounts/keystore"
//	"github.com/ethereum/go-ethereum/common/hexutil"
//	"github.com/ethereum/go-ethereum/crypto"
//	"github.com/google/uuid"
//)
//
//func main() {
//	keyHex := "0x45c418fbe5c252381bf1699d348362d12fc560c01f1be3dd9c576e6e6475caf6"
//	auth := "my secret"
//	fmt.Println("original: ", keyHex)
//
//	encoded := encode(keyHex, auth)
//	fmt.Println("encoded: ", string(encoded))
//
//	//decoded := decode(encoded, auth)
//	//fmt.Println("decoded: ", decoded)
//}
//
//func encode(keyHex, auth string) []byte {
//	prvKey, err := crypto.HexToECDSA(keyHex[2:])
//	assert(err)
//	key := &keystore.Key{
//		Id:         uuid.New(),
//		Address:    crypto.PubkeyToAddress(prvKey.PublicKey),
//		PrivateKey: prvKey,
//	}
//	json, err := keystore.EncryptKey(key, auth, keystore.StandardScryptN, keystore.StandardScryptP)
//	assert(err)
//	return json
//}
//
//func decode(json []byte, auth string) string {
//	key, err := keystore.DecryptKey(json, auth)
//	assert(err)
//	return hexutil.Encode(crypto.FromECDSA(key.PrivateKey))
//}
//
//func assert(err error) {
//	if err != nil {
//		panic(err)
//	}
//}
